Cloud Design Patterns
About the Example
|
This document describes the Static Content Hosting Pattern example from the guide Cloud Design Patterns (see http://aka.ms/Cloud-Design-Patterns).
Before you start
Ensure that you have installed all of the software prerequisites. For details see the Release Notes.
The example demonstrates operational aspects of applications running in Windows Azure. Therefore, you will need to use the diagnostics tools in order to understand how the code sample works. You must ensure that the web and worker roles in the solution are configured to use the diagnostics mechanism. If not, you will not see the trace information generated by the example.
About the Example
This example shows how to reference static content from a publicly accessible storage service. The example contains a Windows Azure web role, which hosts a web application that references JavaScript files and images deployed to a Windows Azure storage account. This type of content is typically deployed to the storage account as part of the application deployment process. However, to simplify the example, these files are deployed to the storage account when the application starts up.
The JavaScript and stylesheet content is referenced in the file App_Start\BundleConfig.cs by using a CDN URL. The image content is referenced in the file Views\Home\Index.cshtml. The URLs are generated by an HTML helper class implemented in the file StaticContentUrlHtmlHelper.cs.
When running the application in release mode, you should note that these static resources are served out of the storage account, as opposed to being delivered by the application server.
Running the Example
You can run this example locally in the Visual Studio Windows Azure emulator. You can also run this example by deploying it to a Windows Azure Cloud Service.